home *** CD-ROM | disk | FTP | other *** search
/ Power DOS 1996 July / Power DOS - July 1996.iso / sound / c_labs / devinfo / mpu401.exe / MIDITEST.C next >
C/C++ Source or Header  |  1996-04-18  |  5KB  |  127 lines

  1. /* -------------------------------------------------------------------------- */
  2. /* THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY      */
  3. /* KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE        */
  4. /* IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A PARTICULAR      */
  5. /* PURPOSE.                                                                   */
  6. /*                                                                            */
  7. /* You have a royalty-free right to use, modify, reproduce and                */
  8. /* distribute the Sample Files (and/or any modified version) in               */
  9. /* any way you find useful, provided that you agree that                      */
  10. /* Creative has no warranty obligations or liability for any Sample Files.    */
  11. /*----------------------------------------------------------------------------*/
  12.  
  13.  
  14. /* ---------------------------------------------------------------------------
  15.   Program:  Sound Blaster 16 MIDI test program
  16.   Filename: MIDITEST.C
  17.   Author:   Scott E. Sindorf
  18.   Date:     30 Jun 93
  19.   Language: Borland C
  20.   
  21.   Copyright (c) 1993-1996 Creative Labs, Inc.
  22. -----------------------------------------------------------------------------*/
  23.  
  24. #include <stdio.h>
  25. #include <conio.h>
  26. #include "sbcutils.h"
  27. #include "midiutil.h"
  28.  
  29. extern BLASTREC blastInfo;
  30.  
  31. const char blastErr[] = "\n\007Error - BLASTER environment variable not found.";
  32. const char MPUAddrErr[] = "\n\007Error - MPU-401 port address field is missing in \
  33. BLASTER environment variable.";
  34.  
  35. const char BasAddrErr[] = "\n\007Error - Base address field is missing in \
  36. BLASTER environment variable.";
  37.  
  38. const char noPortErr[] = "\n\007Error - MIDI hardware not detected.";
  39. const char initErr[] = "\n\007Error - Unable to initialize MIDI port";
  40.  
  41. void main(void)
  42. {
  43.   char keyboard;
  44.  
  45.   printf("Do you have a MIDI input device connected? (Y,N) ");
  46.   keyboard = getch();
  47.   printf("\n\n");
  48.  
  49.   if(GetBlastInfo(&blastInfo) == OK)      // get BLASTER environment variable
  50.   {
  51.     printf("\n\tBLASTER environment variable was found\n\n");
  52.  
  53.                           //----------------------//
  54.                           // MPU-401 Example Code //
  55.                           //----------------------//
  56.     MIDIType = MPU401;
  57.     printf("\tMIDI interface = MPU-401\n");
  58.     if(blastInfo.midiPort != 0)           // was MPU-401 port found?
  59.     {
  60.       printf("\tMPU-401 port address is %Xh\n", blastInfo.midiPort);
  61.       if(Detect_MIDI() == OK)             // was hardware detected?
  62.       {
  63.         printf("\tHardware was detected\n");
  64.         if(Init_MIDI() == OK)             // initialize MPU-401 port
  65.         {
  66.           printf("\tMPU-401 port initialized properly\n");
  67.  
  68.           if((keyboard == 'Y') || (keyboard == 'y'))
  69.           {
  70.             printf("\n\tMIDI Thru test  -  Hit any key to continue\n\n");
  71.             while(!kbhit())
  72.               Write_MPU401_Data(Read_MPU401_Data());
  73.             getch();                      // clear keystroke
  74.           }
  75.  
  76.           Exit_MIDI();
  77.           printf("\tMIDI driver has been terminated\n\n");
  78.         }
  79.         else
  80.           printf(initErr);
  81.       }
  82.       else
  83.         printf(noPortErr);
  84.     }
  85.     else
  86.       printf(MPUAddrErr);
  87.  
  88.                           //---------------------//
  89.                           // SBMIDI Example Code //
  90.                           //---------------------//
  91.     MIDIType = SBMIDI;
  92.     printf("\tMIDI interface = SBMIDI\n");
  93.     if(blastInfo.baseAddr != 0)           // was base Address found?
  94.     {
  95.       printf("\tSound Blaster base address is %Xh\n", blastInfo.baseAddr);
  96.       if(Detect_MIDI() == OK)             // was hardware detected?
  97.       {
  98.         printf("\tHardware was detected\n");
  99.         if(Init_MIDI() == OK)             // initialize SBMIDI
  100.         {
  101.           printf("\tSBMIDI initialized properly\n");
  102.  
  103.           if((keyboard == 'Y') || (keyboard == 'y'))
  104.           {
  105.             printf("\n\tMIDI Thru test  -  Hit any key to continue\n\n");
  106.             while(!kbhit())
  107.               Write_SBMIDI_Data(Read_SBMIDI_Data());
  108.             getch();                      // clear keystroke
  109.           }
  110.  
  111.           Exit_MIDI();
  112.           printf("\tMIDI driver has been terminated\n");
  113.         }
  114.         else
  115.           printf(initErr);
  116.       }
  117.       else
  118.         printf(noPortErr);
  119.     }
  120.     else
  121.       printf(BasAddrErr);
  122.     }
  123.     else
  124.         printf(blastErr);
  125. }
  126.  
  127.